package com.ada.base.security.controller;

import com.ada.base.common.ApiResponse;
import com.ada.base.common.ControllerResponse;
import com.ada.base.security.entity.res.AuthorityRes;
import com.ada.base.security.service.AuthorityService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "权限")
@RequestMapping("base/authority")
@RestController
public class BaseAuthorityController extends ControllerResponse {
    private AuthorityService authorityService;

    public BaseAuthorityController(AuthorityService authorityService) {
        this.authorityService = authorityService;
    }

    @GetMapping
    public ApiResponse<List<AuthorityRes>> authorityList() {
        return ok(authorityService.authorityList());
    }

    @GetMapping("/{roleId}")
    public ApiResponse<List<AuthorityRes>> authorityList(@PathVariable("roleId") long roleId) {
        return ok(authorityService.findAuthorityByRoleId(roleId));
    }
}
